package com.example.Lezedata.ui.activity.baseClass;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.example.Lezedata.R;

public class GBListViewNoDataBaseAdapter extends BaseAdapter {
    public ListView listView;
    LinearLayout noDataView;

    public GBListViewNoDataBaseAdapter(ListView listView){
        this.listView = listView;
    }
    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return null;
    }

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
        if (getCount() == 0){
            addNoDataView();
        }else {
            removeNoDataView();
        }
    }

    void addNoDataView(){
        noDataView = (LinearLayout) LayoutInflater.from(listView.getContext()).inflate(R.layout.nodata,listView,false);
        listView.addHeaderView(noDataView);
    }

    void removeNoDataView(){
        if (noDataView == null){
            return;
        }
        listView.removeHeaderView(noDataView);
    }
}
